package logic

import (
	"context"
	"post/docker/mysql"
	"post/postrpc/internal/svc"
	"post/postrpc/postrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RecordShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRecordShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecordShowLogic {
	return &RecordShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RecordShowLogic) RecordShow(in *postrpc.RecordShowRequest) (*postrpc.RecordShowResponse, error) {
	// todo: add your logic here and delete this line

	var records mysql.Record
	mysql.DB.Debug().Where("id=?", in.Id).Find(&records)
	record := mysql.Record{

		Title:      records.Title,
		Comment:    records.Comment,
		UserId:     records.UserId,
		ActivityId: records.ActivityId,
		ClassId:    records.ClassId,
	}

	return &postrpc.RecordShowResponse{
		Id: int64(record.ID),
	}, nil
}
